//
//  EPMTitleView.m
//  myXianfeng
//
//  Created by 马继鵬 on 17/5/4.
//  Copyright © 2017年 EPM. All rights reserved.
//

#import "EPMTitleView.h"

@implementation EPMTitleView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]){
        [self setupUI];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setupUI{
    
    UIControl* control = [[UIControl alloc]init];
    [self addSubview:control];
    
    [control mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.center.equalTo(self);
    }];
    
    UILabel* label = [[UILabel alloc]init];
    [control addSubview:label];
    label.text = @"综合排序-全部分类";
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.equalTo(control);
        make.leading.centerY.equalTo(control);
    }];
    [label sizeToFit];
    
    UIImageView* imgView = [[UIImageView alloc]init];
    [control addSubview:imgView];
    imgView.image = [UIImage imageNamed:@"cell_arrow_down_accessory"] ;
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(label.mas_trailing).offset(10);
        make.centerY.equalTo(label);
        make.width.mas_equalTo(14);
        make.height.mas_equalTo(7);
        make.trailing.bottom.equalTo(control);
        
    }];
    
   [ control addTarget:self action:@selector(actionControlClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

- (void)actionControlClicked:(UIControl*)sender{
    
    if(self.titleViewClicked){
        self.titleViewClicked();
    }
    
}

@end
